package com.zryc.shop.ums.controller;

import com.zryc.shop.base.Result;
import com.zryc.shop.ums.entity.Resource;
import com.zryc.shop.ums.entity.ResourceCategory;
import com.zryc.shop.ums.service.IResourceCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

/**
 * <p>
 * 资源分类表 前端控制器
 * </p>
 *
 * @author zhaozhao
 * @since 2024-01-16
 */
@RestController
@Api(tags = "资源分类管理接口列表")
@RequestMapping("/ums/resourceCategory")
public class ResourceCategoryController {

    @Autowired
    private IResourceCategoryService resourceCategoryService;
    @GetMapping("/listAll")
    @ApiOperation("分页查询全部资源模块列表")
    public Result listAll() {
        return Result.ok(resourceCategoryService.list());
    }

    @PostMapping("/delete/{id}")
    @ApiOperation("删除资源模块")
    public Result delete(@PathVariable @ApiParam(value = "资源模块id", required = true) Long id) {
        return Result.ok(resourceCategoryService.deleteById(id));
    }

    @PostMapping("/create")
    @ApiOperation("新增资源模块")
    public Result create(@RequestBody ResourceCategory resourceCategory) {
        return Result.ok(resourceCategoryService.save(resourceCategory));
    }

    @PostMapping("/update/{id}")
    @ApiOperation("更新资源模块信息")
    public Result update(@PathVariable @ApiParam(value = "资源id", required = true) Long id, @RequestBody ResourceCategory resourceCategory) {
        return Result.ok(resourceCategoryService.updaterResourceCategory(id, resourceCategory));
    }
}
